import {
    PropsConfigs
} from "db://assets/proto/shared/v1/configs";
import {GlobalConfigsLoader} from "db://assets/script/global-configs-loader";

import {resources, SpriteFrame} from "cc";

export class PropsConfigsLoader {

    findPropConfigs(propId: number): PropsConfigs | undefined {
        const flc = GlobalConfigsLoader.instance.getPropsConfigs()
        const key = propId.toString()
        return flc.get(key)
    }

    findPropIcon(propId: number): SpriteFrame | null {
        const pc = this.findPropConfigs(propId)!
        return resources.get('textures/props/' + pc.icon + '/spriteFrame', SpriteFrame)
    }

}

export const propsConfigsLoader = new PropsConfigsLoader();